﻿// JavaScript Document
//var HostUrl = "http://127.0.0.1/netdog/";
var HostUrl = "http://www.51hhww.com/";
function SendAjax( _url, _callback )
{
	var paramJson = 
	{
		method:"GET",
		url: HostUrl + _url,
		param:"",
		isAsynchronous:true,
		onComplete:_callback
	};
	
	var ajax = new Ajax();
	ajax.sendRequest(paramJson);
}

function GetUrlParam(szParamName)
{	
	var strResult = "";
	var nStart = 0;
	var nEnd = 0;
	var start = 0;
	var end = 0;
	var strLoc = location.href.toLowerCase();
	szParamName = szParamName.toLowerCase();
	nStart = strLoc.indexOf("?", 1);
	if (nStart == -1)
		return"";
		
	//
	nStart = strLoc.indexOf(szParamName, nStart);
	if (nStart == -1)
		strResult = "";
	else
	{
		//nEnd = InStr(nStart, location.href, "&");	
		nEnd = strLoc.indexOf( "&", nStart);
		if ( nEnd == -1 )
		{
			//strResult = mid(location.href, nStart + len(szParamName));
			strResult = strLoc.substring(nStart + szParamName.length )
		}
		else
		{
			if (nEnd > nStart )	
			{	
				start = nStart + szParamName.length;
				end = nEnd - nStart - szParamName.length;	
				strResult = strLoc.substring( nStart + szParamName.length, nEnd );	
			}		
		}
	}
	return strResult;
}



function GetObj( id )
{
	return document.getElementById( id );
}

function DisPlayDiv( id, bDisplay )
{
	if( bDisplay )
		GetObj( id ).style.display = "";
	else
		GetObj( id ).style.display = "none";
}

function ShowLayer( id , bShow )
{
	if( bShow )
		GetObj( id ).style.visibility = "visible";
	else
		GetObj( id ).style.visibility = "hidden";
}

function SubString( str, iMaxLength )
{
	var iLength = str.length;
	var strResult = "";
	var iCode = 0;
	var nLength = 0;
	for(var i = 0; i < iLength; i++ )
	{
		iCode = str.charCodeAt(i);
		if( iCode < 0 || iCode > 255 )
			nLength += 12;
		else
			nLength += 6;
		
		strResult += str.charAt(i);
		if( nLength > iMaxLength - 24 )
			break;
	}
	if( i >= iLength )
		return str;
	else 
		return strResult + "..";
}

function MaxDiv( id )
{
	var nWidth = document.body.clientWidth;
	var nHeight = document.body.clientHeight;
	
	var LayerObj = GetObj( id );
	LayerObj.style.width = nWidth + 10 + "px";
	LayerObj.style.height = "820px";
}

function isemail(str)
{
	var result=str.match(/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
	if(result == null )
		return false;
	return true;
}

function isnumber(str)
{
	return !isNaN(str);
}

function isphone( str )
{
	var result = str.match(/^(13|15|16|18|14)[0-9]{9}$/ );
	if(result==null)
		return false;
	return true;
}

function OnHomePage()
{
	window.top.location.href = "http://www.51hhww.com";
}

function getCookie(c_name)
{
 if (document.cookie.length > 0)
 {
  c_start = document.cookie.indexOf(c_name + "=")
  if (c_start != -1)
  {
   c_start = c_start + c_name.length + 1;
   c_end   = document.cookie.indexOf(";",c_start);
   if (c_end == -1) 
   {
    c_end = document.cookie.length;
   }
   return unescape(document.cookie.substring(c_start,c_end));
  } 
 }
 return null
}
/********************************************************************
* 函数名:
* setCookie
*
* 参数:
* c_name  - Cookie名称
*   value  - Cookie内容
*   expiredays - Cookie日期
*
* 返回值:
* 空
* 
* 说明:
* 该函数设置Cookie保留用户上次登录方式
********************************************************************/
function setCookie(c_name,value,expiredays)
{
 var exdate = new Date();
 exdate.setDate(exdate.getDate() + expiredays);
 // 使设置的有效时间正确。增加toGMTString()
 document.cookie = c_name + "=" +escape(value) + ((expiredays == null) ? "" : ";path=/;expires=" + exdate.toGMTString());
}